package com.supkong.java.predicate;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: jdk8-learning-example
 * @author: Kong
 * @create: 2020-04-09 16:21
 * @description:
 */
public class Test {

    public static void main(String[] args) {
        Apple a = new Apple("red",140);
        Apple b =  new Apple("green",130);
        List<Apple> apples = new ArrayList<>();
        apples.add(a);
        apples.add(b);
        //方式一
        System.out.println(AppUtils.filterApples(apples,Apple::isGreenApple));
        //方式二
        System.out.println(AppUtils.filterApples(apples,(Apple apple) -> "green".equals(apple.getColor())));
        //方式三
        System.out.println( apples.stream().filter(Apple::isGreenApple).collect(Collectors.toList()));
    }
}
